package adapter;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Parcelable.Creator;
import android.util.Log;

public class DbOpenHelper extends SQLiteOpenHelper{
	private static final String DB_NAME = "sonntNEC.db";
	private static final int DB_VERSION = 1;
	private static final String DB_TABLE = "mainTable";
	private static final String DB_CREATE = "CREATE TABLE " + DB_TABLE 
						+ "(_id integer primary key autoincrement, " 
						+ "name text not null, "
						+ "age integer);";
	public DbOpenHelper(Context context){
		super(context, DB_NAME, null, DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		Log.v("DB", DB_CREATE);
		db.execSQL(DB_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE);
		onCreate(db);
	}
}
